<template>
  <view class="addAddress">
    <view class="box">
      <view class="line">
        <view class="title">联系人</view>
        <view class="choose">
          <u-input
            placeholder="请填写联系人"
            border="none"
            v-model="real_name"
            :customStyle="inputStyle"
          ></u-input>
        </view>
      </view>
      <view class="line">
        <view class="title">联系电话</view>
        <view class="choose">
          <u-input
            placeholder="请填写联系电话"
            border="none"
            v-model="phone"
            :customStyle="inputStyle"
          ></u-input>
        </view>
      </view>
	  <view class="line">
	    <view class="title">微信号</view>
	    <view class="choose">
	      <u-input
	        placeholder="请填写微信号"
	        border="none"
	        v-model="wechat"
	        :customStyle="inputStyle"
	      ></u-input>
	    </view>
	  </view>
	  <!-- <view class="line">
	    <view class="title">联系邮箱</view>
	    <view class="choose">
	      <u-input
	        placeholder="请填写联系邮箱"
	        border="none"
	        v-model="postcode"
	        :customStyle="inputStyle"
	      ></u-input>
	    </view>
	  </view> -->
      <view class="btn" @click="cancel">确认申请</view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      // 收货人
      real_name: "",
      // 联系方式
      phone: "",
	  // 微信号
	  wechat:"",
	  // 邮箱
	  postcode:""
    };
  },

  onLoad(options) {
	
  },

  methods: {
    // 确认添加
    cancel() {
      if (!this.real_name) {
        this.$u.toast("请填写联系人信息");
        return;
      }
      if (!this.phone) {
        this.$u.toast("请填写联系电话");
        return;
      }
	  if (!this.wechat) {
	    this.$u.toast("请填写微信号");
	    return;
	  }
	  // if (!this.postcode) {
	  //   this.$u.toast("请填写联系邮箱");
	  //   return;
	  // }
      let info = {
        name: this.real_name,
        phone: this.phone,
		wechat:this.wechat
		// email:this.postcode
      };
	  if(this.id){
		  info.id = this.id;
	  }
	  this.$api.post({
	      url: "/ebapi/public_api/applyAgent",
	      data: info,
	      success: (res) => {
			uni.showToast({
				title:"申请成功，请等待审核！"
			})
			setTimeout(()=>{
				uni.navigateBack()
			},1000)
	  	},
	   })
    },
  },
};
</script>

<style lang="scss">
.addAddress {
  padding: 24rpx;
  font-size: $uni-text-size-middle;

  .box {
    padding: 60rpx 40rpx;
    background: #ffffff;
    box-shadow: 0rpx 2rpx 10rpx 1rpx rgba(0, 0, 0, 0.08);
    border-radius: 16rpx;
    opacity: 1;

    .line {
      margin-bottom: 34rpx;

      .title {
        font-size: $uni-text-size-middle;
        margin-bottom: 20rpx;
        color: #666666;
      }
    }

    .btn {
      margin-top: 135rpx;
      padding: 30rpx 0;
      border-radius: 50rpx;
      text-align: center;
      color: #ffffff;
      font-size: $uni-text-size-title;
      background: #2354e3;
      opacity: 1;
    }
  }
}
</style>
